using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.Winshell
{
    using ListView = System.Windows.Forms.ListView;
    using Form = System.Windows.Forms.Form;
    using IExternalTools= My.IdlConverter.ThirdParty.IExternalTools;

    abstract class  ListViewItemTag
    {
        private ListView listView;
        private object tag;

        public ListViewItemTag(ListView listView,object tag)
        {
            this.listView = listView;
            this.tag = tag;
        }

        public object Tag
        {
            get {return tag;}
        }

       public ListView ListView
       {
           get { return listView; }
       }

        public abstract void DoRun();
    }

    class SdkMachineViewItemTag : ListViewItemTag
    {
        private Form parent;

        public SdkMachineViewItemTag(ListView listView, object tag, Form parent)
            :base(listView,tag)
        {
            this.parent = parent;
        }

        public override void DoRun()
        {
            Form form = Tag as Form;
            form.ShowDialog(parent);
        }
    }

    class ScriptCodeToolItemTag : ListViewItemTag
    {
        private Form parent;

        public ScriptCodeToolItemTag(ListView listView, object tag, Form parent)
            : base(listView, tag)
        {
            this.parent = parent;
        }

        public override void DoRun()
        {
            Form form = Tag as Form;
            form.ShowDialog(parent);
        }
    }

    class ExternalToolViewItemTag : ListViewItemTag
    {
        private string param;

        public ExternalToolViewItemTag(ListView listView, object tag, string param)
            :base(listView,tag)
        {
            this.param = param;
        }

        public override void DoRun()
        {
            IExternalTools cryptoTools = Tag as IExternalTools;
            cryptoTools.DoRun(param);
        }
    }

    class AddRegistrationToolViewItemTag : ListViewItemTag
    {
        private Form parent;
        private RegistrationForm form;

        public AddRegistrationToolViewItemTag(ListView listView, object tag, Form parent)
            : base(listView, tag)
        {
            this.parent = parent;
            this.form = (RegistrationForm)tag;
        }

        public override void DoRun()
        {
            form.ShowDialog(parent);
        }
    }
}
